<?php
  echo $this->Html->css('calendar/fullcalendar');
?>

<?php
$this->Paginator->options(array(
    'update' => '#content-outer',
    'evalScripts' => false,
    'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
    'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
));

$pageOption = $this->Paginator->params();
?>
<?php echo $this->Html->image('loading.jpg', array('id' => 'busy-indicator', 'style' => 'display:none;')); ?>

<div id="content">
	<!--  start page-heading -->
	<div id="page-heading">
		<h1>
        <?php echo __('Manage Template'); ?>
        <?php echo $this->Html->link("Add Template", array('action' => 'add'), array("class" => "button")); ?>
        <?php echo $this->Html->link("Send Message", array('action' => 'send'), array("class" => "button")); ?>
    </h1>

	</div>
	<!-- end page-heading -->
	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
	<tr>
		<th rowspan="3" class="sized">
        <?php echo $this->Html->image('/images/shared/side_shadowleft.jpg', array('width' => '20', 'height' => '300', 'alt' => '')); ?>
    </th>
		<th class="topleft"></th>
		<td id="tbl-border-top">&nbsp;</td>
		<th class="topright"></th>
		<th rowspan="3" class="sized">
        <?php echo $this->Html->image('/images/shared/side_shadowright.jpg', array('width' => '20', 'height' => '300', 'alt' => '')); ?>
    </th>
	</tr>
	<tr>
		<td id="tbl-border-left"></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		
			<!--  start table-content  -->

		<div id="content-table-inner">
                    <?php 
                            echo $this->Session->flash();
                        ?>
				<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
				<tr>
                                        <th class="table-header-repeat line-left minwidth-1">
                                            <?php echo $this->Paginator->sort('name', 'Name'); ?>
                                       </th>
                                        <th class="table-header-repeat line-left">
                                            Action
                                       </th>          
				</tr>

                                <?php foreach ($messages as $message): ?>
                                    <tr>
                                        <td>
                                            <?php echo $message['Message']['name']; ?>
                                        </td>
                                        <td class="actions">
                                            <?php echo $this->Html->link('View', array('action' => 'view', $message['Message']['id'], 'admin' => true)); ?>
                                            <?php echo $this->Html->link('Edit', array('action' => 'edit', $message['Message']['id'], 'admin' => true)); ?>
                                            <?php if($message['Message']['is_deleted'] == 1){ 
                                                  echo $this->Html->link(
                                                      'Delete',
                                                      array('controller' => 'messages', 'action' => 'delete', $message['Message']['id'], 'admin' => true),
                                                      array(),
                                                      "Are you sure you wish to delete this template?"
                                                  );
                                             } 
                                            ?>
                                        </td>
                                    </tr>
                                <?php endforeach; ?>

  </table>
			<div class="clear"></div>
		<!--  start paging..................................................... -->
  <? if($pageOption['pageCount'] > 1): ?>	
    <table border="0" cellpadding="0" cellspacing="0" id="paging-table">
        <?php echo $this->element('pagination');?>       
		</table> 
		<!--  end paging................ -->
  <? endif; ?>	

		</div>
	 
			  <?php //echo $this->element("Tickets".'/listing'); ?>
      <!--  end content-table  -->
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>

</div>
<?php
    echo $this->Js->writeBuffer();
?>	
<style>
#paging-table a {
  padding: 0 12px 12px;
}
</style>
<script type="text/javascript">
  jQuery(document).ready(function() {
    jQuery("#messagesMenu").addClass("current");
  });
</script>